//
//  SLModalTransitionDelegate.m
//  CustomModalTransition
//
//  Created by 朱志佳 on 2019/4/4.
//  Copyright © 2019 朱志佳. All rights reserved.
//

#import "SLModalTransitionDelegate.h"
#import "SlideAnimationController.h"

#import "OverlayAnimationController.h"
#import "OverlayPresentationController.h"

#define SLOverlayAnimationController

@implementation SLModalTransitionDelegate

- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    NSLog(@"%@##%@",NSStringFromClass([self class]),NSStringFromSelector(_cmd));
#ifdef SLOverlayAnimationController
    return [OverlayAnimationController new];

#else
    //转场 slide 实现
    NSUInteger transitionType = TransitionTypePresention;
    SlideAnimationController *slide = [[SlideAnimationController alloc] init];
    slide.transitionType = transitionType;
    return slide;
#endif

}

- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    NSLog(@"%@##%@",NSStringFromClass([self class]),NSStringFromSelector(_cmd));
#ifdef SLOverlayAnimationController
    return [OverlayAnimationController new];

#else
    //转场 slide 实现
    NSUInteger transitionType = TransitionTypeDismissal;
    SlideAnimationController *slide = [[SlideAnimationController alloc] init];
    slide.transitionType = transitionType;
    return slide;
#endif
}

//- (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator;

//- (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator;

////在transition过程中处理其他的动画
// delegate-弹出视图代理

// 返回控制控制器弹出动画的对象
/**
 presentedViewController     将要跳转到的目标控制器
 presentingViewController    跳转前的原控制器
 */
-(UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source NS_AVAILABLE_IOS(8_0){
#ifdef SLOverlayAnimationController
    return [[OverlayPresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting];
#else
    return nil;
#endif
}

@end
